﻿<%@ Page Title="ScrumPeak.com" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
  AutoEventWireup="true" Inherits="System.Web.Mvc.ViewPage<Sprint>" %>

<%@ Import Namespace="Peak.ApplicationServices" %>
<%@ Import Namespace="Peak.Web.Controllers.HtmlExtentions" %>
<%@ Import Namespace="Peak.Resources" %>
<%@ Import Namespace="Peak.Web.Controllers" %>
<%@ Import Namespace="Peak.Core" %>
<%@ Import Namespace="Peak.Web.Controllers.Models" %>
<asp:Content ContentPlaceHolderID="center" runat="server">

  <script type="text/javascript">
    swfobject.embedSWF("<%= ResolveUrl("~/Content/open-flash-chart.swf") %>", "burndownChart", "100%", "<%= SprintController.BurndownHeight %>", "9.0.0", "expressInstall.swf", { "data-file": "<% =Html.BuildUrlFromExpression<SprintController>(f=>f.Burndown(Model.Id)) %>" });
  </script>

  <script type="text/javascript">
    $(function() {
      setTableMultiSelect();
    });            

    $(function() {
      $('#checkAll').change(function() {
      $("#tableForm input[type='checkbox']:not([disabled='disabled'])").each(function(index, item)
      {
        if($('#checkAll').is(':checked'))
        {
          if(!item.checked)
            this.click()
        }        
        else
        {
          if(item.checked)
            this.click()
        }
      })
      });
    });
  </script>

  <div class="page-content">
    <div class="page-title">
      <%= PageTitles.SprintDetails %>
    </div>
    <table width="100%">
      <tr>
        <td width="350px" valign="top">
          <table class="form" style="width:100%;">
            <tbody>
              <tr>
                <td class="formLabel" align="right">
                  <%= Labels.Name %>
                </td>
                <td class="formData">
                  <%= Model.Name %>
                </td>
              </tr>
              <tr>
                <td class="formLabel" align="right">
                  <%= Labels.Description %>
                </td>
                <td class="formData">
                  <%= Model.Description %>
                </td>
              </tr>
              <tr>
                <td class="formLabel" align="right">
                  <%= Labels.RemainingEffort %>
                </td>
                <td class="formData">
                  <%= DurationParser.ToString(Model.RemainingEffort) %>
                </td>
              </tr>
              <tr>
                <td class="formLabel" align="right">
                  <%= Labels.RealVelocity%>
                </td>
                <td class="formData">
                  <%= Model.RealVelocity %>
                </td>
              </tr>
              <tr>
                <td class="formLabel" align="right">
                  <%= Labels.EstimatedVelocity%>
                </td>
                <td class="formData">
                  <%= Model.EstimatedVelocity %>
                </td>
              </tr>
              <tr>
                <td class="formLabel" align="right">
                  <%= Labels.Start %>
                </td>
                <td class="formData">
                  <%= Model.StartDate.ToShortDateString() %>
                </td>
              </tr>
              <tr>
                <td class="formLabel" align="right">
                  <%= Labels.Status %>
                </td>
                <td class="formData">
                  <%= Model.Status %>
                </td>
              </tr>
              <tr>
                <td class="formLabel" align="right">
                  <%= Labels.End %>
                </td>
                <td class="formData">
                  <%= Model.EndDate.ToShortDateString() %>
                </td>
              </tr>
              <tr>
                <td>
                </td>
                <td>
                  <%= Html.PeakButton<SprintController>(f => f.Edit(Model.Id), Buttons.Edit)%>    
                  <%= Html.PeakButton<SprintController>(f => f.Back(), Buttons.Back)%>                                        
                </td>
              </tr>
            </tbody>
          </table>
        </td>
        <td>
          <div id="burndownChart" class="burndownChart">
            &nbsp;
          </div>
        </td>
      </tr>
    </table>
    <br />
    <h3><%= Labels.Stories %></h3>
    <div class="separator">
    </div>
    <% if (Model.Status != SprintStatus.Finished)
       {%>
    <%=Html.PeakButton<SprintController>(f => f.SelectStories(Model.Id), Buttons.Add)%>
    <%=Html.PeakRemoveButton<SprintController>(f => f.RemoveStories(Model.Id, null), "tableForm")%>
    <%
       }%>
    <%= Html.PeakSubmitButton<PrintController>(f => f.Stories(null), Buttons.Print, "tableForm")%>
    <form id="tableForm" method="post">
    <table class="table">
      <thead>
        <tr>
          <th class="autoWidthColumn">
            <input id="checkAll" type="checkbox" />
          </th>
          <th class="autoWidthColumn">
            <%= Columns.Id %>
          </th>
          <th class="autoWidthColumn">
            <%= Columns.Category %>
          </th>
          <th>
            <%= Columns.Name %>
          </th>         
          <th width="100px">
            <%= Columns.StatusInSprint %>
          </th>
          <th width="10px">
            <%= Columns.StoryPoints %>
          </th>
          <th width="10px">
            <%= Columns.Priority %>
          </th>
          <th width="10px">
            <%= Columns.RemainingEffort %>
          </th>
        </tr>
      </thead>
      <tbody>
        <% foreach (SprintStory sprintStory in Model.SprintStories.OrderByDescending(f => f.Story.Priority))
           { %>
        <tr>
          <td align="center">
            <input type="checkbox" name="ids" value="<%= sprintStory.Story.Id %>" />
          </td>
          <td align="center">
            <%= sprintStory.Story.Id%>
          </td>
          <td align="center">
            <%= sprintStory.Story.Category%>
          </td>
          <td>
            <%= Html.ActionLink<StoryController>(f => f.Index(sprintStory.Id, null), sprintStory.Story.Name)%>
            <%= Html.Edit<StoryController>(f => f.Edit(sprintStory.Story.Id))%>
          </td>          
          <td width="100px">
            <%= Html.Status(sprintStory.Status) %>
          </td>
          <td width="10px" align="center">
            <%= sprintStory.StoryPoints%>
          </td>
          <td width="10px" align="center">
            <%= sprintStory.Story.Priority%>
          </td>
          <td width="10px" align="center">
            <%= DurationParser.ToString(sprintStory.RemainingEffort)%>
          </td>
        </tr>
        <% } %>
        <% if (ViewData.Model.SprintStories.Count == 0)
           {%>
        <tr>
          <td colspan="10">
            <%= Messages.NoResults%>
          </td>
        </tr>
        <% } %>
      </tbody>
    </table>
    </form>
  </div>
</asp:Content>
